<template>
  <div id="app">
    <router-view/>
  </div>
</template>

<style>
html, body, #app {
  height: 100%;
  width: 100%;
  margin: 0;
}

#app {
  background-image: url("../src/assets/images/login.jpg");
}
</style>
<script>
import Login from './views/Login.vue'

export default {
  name: "App",
  components: {
    Login
  },
  mounted() {
/*    通过监听unload方法，重载页面就把state存入
    sessionStorage，然后在需要state的时候从sessionStorage中取值，以此来解决刷新页面使得vuex state初始化的问题*/
    window.addEventListener('unload', this.saveState)
  },
  methods: {
    saveState() {
      sessionStorage.setItem('state', JSON.stringify(this.$store.state))
    }
  }
}
</script>
